#
# FEDData.py
#
# Data models for Federal Documents processing.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Copyright 2009- Jeremy Nelson, Tomichi Informatics
#
import datetime,os

import FRBRData,MODSData
from basedata import *

# Google classes
from google.appengine.ext import db
from google.appengine.api import users

#==============================================================================#
# Custom FRBR Manifestation Classes for Government Publications                #
#==============================================================================#
class FederalDocument(FRBRData.Manifestation):
    """Models a United States Federal Document"""
    number = db.ReferenceProperty(MODSData.classification)
    sudoc_item_number = db.StringProperty()
    shipping_lists = db.ListProperty(db.Key)

class FederalMediaDocument(FederalDocument):
    """ Models a CD-ROM, DVD, or other electronic meda format document."""
    format = db.StringProperty(required=False,
                               choices=(['cdrom',
                                         'dvd',
                                         'floppy',
                                         'other']))

#==============================================================================#
# Container and management classes for Federal documents                       #
#==============================================================================#
class FederalShippingList(BaseModel):
    """Stores Federal shipping list of material."""
    processed_by = db.UserProperty()
    processed_on = db.DateProperty()
    verified_by = db.UserProperty()
    verified_on = db.DateProperty(auto_now_add=True)
    type_of = db.StringProperty(required=True,
                                choices=(["print",
                                          "microfiche",
                                          "electronic",
                                          "separate"]))
    number = db.StringProperty(required=True)
    date = db.DateProperty()
    items = db.ListProperty(db.Key,
                            default=None)
        

class AlternativeShippingList(BaseModel):
    """Stores alternative federal shipping list."""
    processed_by = db.UserProperty()
    processed_on = db.DateProperty()
    verified_by = db.UserProperty()
    verified_on = db.DateProperty(auto_now_add=True)
    type_of = db.StringProperty(required=True,
                                choices=(["blm",
                                          "dod",
                                          "forest service"]))
    date = db.DateProperty()
    items = db.ListProperty(db.Key)

class SudocClass(BaseModel):
    ''' Stores Federal Document Sudoc classes with
        class, title, item number, and format '''
    class_name = db.StringProperty(required=True)
    title = db.StringProperty(required=True)
    item_number = db.StringProperty(required=True)
    is_org = db.BooleanProperty(default=False)
    format = db.StringProperty(required=False,
                               choices=(['paper',
                                         'microfiche',
                                         'electronic',
                                         'media']))
